from SCBAutoLibrary.base.basekeywords import SCBBaseKeywords

class _ElementExtendKeywords(SCBBaseKeywords):


	def get_element_by_text(self, text, first_only=True):
		elements = self._get_element_with_xpath(text, first_only)
		return elements	

	def get_element_list_with_table_id(self, id):
		t_query = "//table[@id='%s']/tbody/tr" % id
		t_list = self.selenium2lib._element_find(t_query, False, False)
		return t_list

	def get_element_list_with_table_class(self, className):
		t_query = "//table[@class='%s']/tbody/tr" % className
		t_list = self.selenium2lib._element_find(t_query, False, False)
		return t_list	

	def get_element_list_with_ul_id(self, id):
		t_query = "//ul[@id='%s']/li" % id
		t_list = self.selenium2lib._element_find(t_query, False, False)
		return t_list

	def get_element_list_with_ul_class(self, className):
		t_query = "//ul[@class='%s']/li" % className
		t_list = self.selenium2lib._element_find(t_query, False, False)
		return t_list

	def _get_element_with_xpath(self, text, first_only=True, required=False):
		t_xpath = "xpath=//*[contains(text(), '%s')]" % text
		elements = self.selenium2lib._element_find(t_xpath, first_only, required)
		return elements





